home *** CD-ROM | disk | FTP | other *** search
- /*
- * _ s t a c k e r r
- *
- * This file contains the routines that are called from the
- * C68 internal routine for stack checking.
- *
- * _stack_error When a failure occurs
- * _stack_newmax When a new maximum value is reached
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <osbind.h>
-
- long _stackmax; /* the maximum space needed on stack */
- long _act_sp; /* actual stack pointer value */
- static long stacksz; /* used to hold stack size during maximum */
-
- extern long _stksize;
- extern long _spbase;
-
-
- static void statistics( void )
- {
- fflush( stdout ); /* clean up */
-
- fprintf( stderr, "\n*** Stack statistics: Size = %lu,"
- " Max used = %lu ***\n", stacksz, _stackmax );
- }
-
- void _stack_error( long new )
- {
- fprintf( stderr, "\n** STACK CHECK ERROR **\n"
- "size:\t%lu\tbytes\n"
- "used:\t%lu\tbytes\n"
- "needed:\t%lu\tbytes\n"
- "*** PROGRAM ABORTED ***\n",
- _stksize, _spbase - _act_sp, new );
-
- Pterm( 127 ); /* Better not use abort() here!!! */
- }
-
- void _stack_newmax( void )
- { static int once = 0;
-
- stacksz = _stksize; /* _stksize might change! */
-
- if ( !once )
- { atexit( statistics );
- once = 1;
- }
- }
-